 <meta charset="UTF-8">

<style>
    * {padding: 0; margin: 0;}
    html,body,#root {
      width: 100%;
      height: 100%;
      overflow: hidden;  
    }
    #root {
      display: flex;
    }
    .menu {
      width: 200px;
      height: 100%;
      background: #263445;
      transition: all 0.3s;
    }
    .menu li {
      width: 100%;
      height: 50px;
      line-height: 50px;
      text-align: center;
      color: rgb(191, 203, 217);
     
    }
    .icon-caidan{
        margin-right: 10px;
    }
    .icon-caidanshouqi{
        font-weight: bold;
    }
    .icon-caidanzhankai{
        font-weight: bold;
    }
    .menu li:hover {
      background: #000;
      color: rgb(191, 203, 217);
      cursor: pointer;
    }
    .main {
      flex: 1;
      background: #fff;
      height: 50px;
      border-bottom: solid 2px #ebeef5;
      box-shadow: 0 1px 4px rgb(0 21 41 / 8%)
    }
    .main .top {
      display: flex;
      padding: 0px 10px;
      height: 100%;
      align-items: center;
      justify-content: space-between;
    }
    .content {
      width: 90%;
      height: 400px;
      margin: auto;
      margin-top: 50px;
    }
    .content div {
      height: 100%;
      box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
      border: 1px solid #ebeef5;
    }
  </style>

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.5.1" />
  <link rel="stylesheet" href="////at.alicdn.com/t/font_3227456_hh2l87f9cnv.css" />
  
  <div id="root">
    <div class="menu" :style="{width: menuWidth}">
      <ul>
        <li @click=" who='index' "><span class="iconfont icon-caidan"></span>{{menuWidth==='200px'? '后台首页' :''}}</li>
        <li @click=" who='goods' "><span class="iconfont icon-caidan"></span>{{menuWidth==='200px'? '商品管理' :''}}</li>
        <li @click=" who='orders' "><span class="iconfont icon-caidan"></span>{{menuWidth==='200px'? '订单管理' :''}}</li>
        <li @click=" who='users' "><span class="iconfont icon-caidan"></span>{{menuWidth==='200px'? '用户管理' :''}}</li>
      </ul>
    </div>
    <div class="main">
      <div class="top">
        <div>
          <span  style="cursor: pointer" @click="changeMenuFn" :class="menuWidth==='200px' ? 'iconfont icon-caidanshouqi' : 'iconfont icon-caidanzhankai'"></span>
          <span style="font-weight:bold;cursor: pointer;margin-left: 10px;">首页 &gt; </span>
          
          <transition appear enter-active-class="animated bounceInRight">
            <span
          v-for="item in [
            {id:1, url: 'index', name: '欢迎页'},
            {id:2, url: 'goods', name: '商品管理'},
            {id:3, url: 'orders', name: '订单管理'},
            {id:4, url: 'users', name: '用户管理'},
          ]"
          v-if="who === item.url"
          :key="item.id"
          style="display: inline-block"
          >{{item.name}}</span
        >
          </transition>
        </div>
        <div style="cursor: pointer" class="iconfont icon-084tuichu"></div>
      </div>
      <div class="content">
        <transition appear enter-active-class="animated fadeInRight">
          <component :is="who"></component>
        </transition>
      </div>
    </div>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
   
    Vue.component("index", {
      template: `
      <div>后台首页</div>
    `,
    });
  
    Vue.component("goods", {
      template: `
      <div>商品管理</div>
   `,
    });
  
    Vue.component("orders", {
      template: `
      <div>订单管理</div>
    `,
    });
  
    Vue.component("users", {
      template: `
      <div>用户管理</div>
    `,
    });
  
    const vm = new Vue({
      el: "#root",
      data: {
        who: "index",
        menuWidth: "200px",
      },
      methods: {
        changeMenuFn() {
          this.menuWidth = this.menuWidth == "200px" ? "64px" : "200px";
        },
      },
    });
  </script>
  